<?php

/**
 * XHTML_Param, xhtml_lib
 * 
 * This file contains the source code for the XHTML_Param class.
 * @author Fernando Jimenez Mocobono <fjmcool@gmail.com>
 * @version 0.1
 * @package xhtml_lib
 */

include_once "XHTML_Common_Element.php";
include_once "XHTML__Object_Content.php";

/**
 * The XHTML_Param class is a handler for the param xhtml-strict tag as a part
 * of a xhtml-strict php-handler implementation.
 */
class XHTML_Param implements XHTML__Object_Content {
    
    // xhtml attributes
    
    /**
     * Unique identifier for this object.
     * 
     * @var string
     */
    protected $id;
    
    /**
     * Unique name for the parameter.
     *
     * @var string
     */
    protected $name;
    
    /**
     * Value of the parameter.
     *
     * @var mixed
     */
    protected $value;
    
    /**
     * MIME type of the value.
     * Valid values: data,ref,object.
     *
     * @var string
     */
    protected $valueType;
    
    /**
     * Internet media type for the parameter.
     *
     * @var string
     */
    protected $type;
    
    // Methods
    
    /**
     * Constructs a XHTML_Param object.
     */
    function __construct()
    {
    }
    
    /**
     * Sets the unique identifier for this object.
     *
     * @param string $id
     */
    function setId($id)
    {
        $this->id = $id;
    }
    
    /**
     * Gets the unique identifier for this object.
     *
     * @return string
     */
    function getId()
    {
        return $this->id;
    }
    
    /**
     * Sets the unique name for the parameter.
     *
     * @param string $name
     */
    function setName($name)
    {
        $this->name = $name;
    }
    
    /**
     * Gets the unique name for the parameter.
     * 
     * @return string
     */
    function getName()
    {
        return $this->name;
    }
    
    /**
     * Sets the value of the parameter.
     * 
     * @param mixed $value
     */
    function setValue($value)
    {
        $this->value = $value;
    }
    
    /**
     * Gets the value of the parameter.
     *
     * @return mixed
     */
    function getValue()
    {
        return $this->value;
    }
    
    /**
     * Sets the MIME type of the value.
     * Valid values: data,ref,object.
     * 
     * @param string $valueType
     */
    function setValueType($valueType)
    {
        $this->valueType = $valueType;
    }
    
    /**
     * Gets the MIME type of the value.
     * Valid values: data,ref,object.
     *
     * @return string
     */
    function getValueType()
    {
        return $this->valueType;
    }
    
    /**
     * Sets the Internet media type for the parameter.
     *
     * @param string $type
     */
    function setType($type)
    {
        $this->type = $type;
    }
    
    /**
     * Gets the Internet media type for the parameter.
     *
     * @return string
     */
    function getType()
    {
        return $this->type;
    }

    // Overriding the toString method for a proper implementation.
    
    /**
    * Returns the string representation for echoing the class atributes.
    *
    * @return string
    */
    function toString()
    {
        $auxString = "<param ";
        
        /*
         * Additions of the object own attributes to the return string.
         */
        
        if (isset($this->id)) {
            $auxString = $auxString."id=\"".$this->id."\" ";
        }
        
        if (isset($this->name)) {
            $auxString = $auxString."name=\"".$this->name."\" ";
        }
        
        if (isset($this->value)) {
            $auxString = $auxString."value=\"".$this->value."\" ";
        }
        
        if (isset($this->valueType)) {
            $auxString = $auxString."valuetype=\"".$this->valueType."\" ";
        }
        
        if (isset($this->type)) {
            $auxString = $auxString."type=\"".$this->type."\" ";
        }
        
        $auxString = $auxString."/>\n";
        
        return $auxString;
    }
    
}

?>